{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Methods "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "they are associated with Objects, they are prebuilt, \n",
    "\n",
    "they are already written in the python language"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = list(range(1,11))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst.insert(4,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10, 9, 8, 7, 4, 6, 5, 4, 3, 2, 1]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "tup = (1,2,3,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tup.count(4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Functions "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Functions are user defined coding blocks which are reusable when ever a user wants to, function are genrally used for programs like, calculator, ATM, "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hiPeople():\n",
    "    \"\"\"\n",
    "    Hi people is function which got created for u All\n",
    "    \"\"\"\n",
    "    print(\"---------\")\n",
    "    print(\"HI ---- \")\n",
    "    print(\"How are u?\")\n",
    "    print(\"---------\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------\n",
      "HI ---- \n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI ---- \n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI ---- \n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI ---- \n",
      "How are u?\n",
      "---------\n"
     ]
    }
   ],
   "source": [
    "hiPeople()\n",
    "hiPeople()\n",
    "hiPeople()\n",
    "hiPeople()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function hiPeople in module __main__:\n",
      "\n",
      "hiPeople()\n",
      "    Hi people is function which got created for u All\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(hiPeople)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hiPeople(name = \"LetsUpgrader!\"):\n",
    "    \"\"\"\n",
    "    Hi people is function which got created for u All\n",
    "    \"\"\"\n",
    "    print(\"---------\")\n",
    "    print(\"HI \",name)\n",
    "    print(\"How are u?\")\n",
    "    print(\"---------\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------\n",
      "HI  Sumit Patil\n",
      "How are u?\n",
      "---------\n"
     ]
    }
   ],
   "source": [
    "hiPeople(\"Sumit Patil\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------\n",
      "HI  raj thite\n",
      "How are u?\n",
      "---------\n"
     ]
    }
   ],
   "source": [
    "hiPeople(\"raj thite\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------\n",
      "HI  LetsUpgrader!\n",
      "How are u?\n",
      "---------\n"
     ]
    }
   ],
   "source": [
    "hiPeople()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = [\"Raj\", \"Sumit\", \"Gaurav\", \"arati\",\" Praniket\",\"Rizwan\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------\n",
      "HI  Raj\n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI  Sumit\n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI  Gaurav\n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI  arati\n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI   Praniket\n",
      "How are u?\n",
      "---------\n",
      "---------\n",
      "HI  Rizwan\n",
      "How are u?\n",
      "---------\n"
     ]
    }
   ],
   "source": [
    "for item in lst:\n",
    "    hiPeople(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gaurav():\n",
    "    \"\"\"\n",
    "    Hi Gaurav this is Doc String this can be used for explaining \n",
    "    what ur function does to outside\n",
    "    world when they call it with the help of HELP()\n",
    "    \"\"\"\n",
    "    print(\"I hope u understand right now\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I hope u understand right now\n"
     ]
    }
   ],
   "source": [
    "gaurav()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function gaurav in module __main__:\n",
      "\n",
      "gaurav()\n",
      "    Hi Gaurav this is Doc String this can be used for explaining \n",
      "    what ur function does to outside\n",
      "    world when they call it with the help of HELP()\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(gaurav)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "def addTwoNumber(num1,num2):\n",
    "    \"\"\"\n",
    "    For addition of two numbers we are making this function\n",
    "    \"\"\"\n",
    "    add = num1+num2\n",
    "    return add"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "addTwoNumber(1,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "addition = addTwoNumber(5625348263,237523552232)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "243148900495"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "addition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = [[1,2],[4,5],[6,7],[166,29464]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 2], [4, 5], [6, 7], [166, 29464]]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1   2\n",
      "4   5\n",
      "6   7\n",
      "166   29464\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[3, 9, 13, 29630]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "resultlst = []\n",
    "for num1, num2 in lst:\n",
    "    print(num1,\" \",num2)\n",
    "    resultlst.append(addTwoNumber(num1,num2))\n",
    "resultlst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "def convertNumbersToThePowerOfFour(num):\n",
    "    return num * num * num * num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "256"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "convertNumbersToThePowerOfFour(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "toThepwerofFour = convertNumbersToThePowerOfFour(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "256"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "toThepwerofFour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(toThepwerofFour)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ***ARGS**  and ****KWARGS**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calcultor_Sub(num1,num2,num3):\n",
    "    return num1 - num2 - num3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "calcultor_Sub() missing 1 required positional argument: 'num3'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-65-bfdbe3d1651e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcalcultor_Sub\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: calcultor_Sub() missing 1 required positional argument: 'num3'"
     ]
    }
   ],
   "source": [
    "calcultor_Sub(20,10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calcultor_Sub(20,10,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calcultor_Add(*anurag):\n",
    "    Add = 0\n",
    "    for item in anurag:\n",
    "        Add = Add + item\n",
    "    return Add"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6138"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calcultor_Add(1,12,56,4,5,5,65,6,6,31,4,12,\n",
    "              423,423,42,4523,423,12,34,35,6,5,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "def personDetails(**maria):\n",
    "    for key, value in maria.items():\n",
    "        print(key, \" - \",value )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name  -  Saikiran\n",
      "mobile  -  874510000000000\n",
      "email  -  sai@itm.edu\n"
     ]
    }
   ],
   "source": [
    "personDetails(name=\"Saikiran\",mobile=\"874510000000000\",email=\"sai@itm.edu\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
